package com.second.app.thread.reentrant.b;

import java.util.concurrent.locks.ReentrantLock;

/**
 * @Author GYZ
 * <pre>
 *
 * </pre>
 */
public class ReentrantLockRun {

    public static void main(String[] args) {
        ReentrantLock reentrantLock = new ReentrantLock();
        for (int j=0;j<5;j++){
            new Thread(() -> {
                reentrantLock.lock();
                for (int i =0;i<10;i++){
                    System.out.println("Thread name="+Thread.currentThread().getName()+"打印了"+(i+1));
                }
                reentrantLock.unlock();
            },"线程"+j).start();
        }
    }
}
